package com.spera.shopoa.util;

import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
/**
 * Created by WoJunyu on 2016/10/12.
 */
public class PoiExcelUtils {
    /**
     * 根据单元格的格式 返回单元格的格式中文
     * @param type_style
     * @return
     */
    public static String getCellStyleByChinese(String type_style) {
        String cell_style_cn = "";
        if(type_style.contains("GENERAL")){
            cell_style_cn = "常规";
        }else if(type_style.equals("_ * #,##0.00_ ;_ * \\-#,##0.00_ ;_ * \"-\"??_ ;_ @_ ")){
            cell_style_cn = "会计专用";
        }else if(type_style.equals("0")){
            cell_style_cn = "整数";
        }else if(type_style.contains("YYYY/MM") || type_style.contains("YYYY\\-MM")){
            cell_style_cn = "日期";
        }else if(type_style.equals("0.00%")){
            cell_style_cn = "百分比";
        }else {
            cell_style_cn = "不符合规定格式类型:"+type_style;
//			cell_style_cn = type_style;
        }
        return cell_style_cn;
    }

    /**
     * 根据索引 返回Sheet
     * @param number
     */
    public static Sheet getSheetByNum(Workbook book,int number){
        Sheet sheet = null;
        try {
            sheet = book.getSheetAt(number-1);
//			if(sheet == null){
//				sheet = book.createSheet("Sheet"+number);
//			}
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
        return sheet;
    }

    /**
     * 初始化格式Map
     */

}
